package cn.shafish.cachedemo.controller;

import cn.shafish.cachedemo.dto.UserDto;
import cn.shafish.cachedemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("get")
    public String getUser(Integer id) {
        UserDto user = userService.getUser(id);
        return user.toString();
    }

    @GetMapping("update")
    public String updateUser(Integer id) {
        UserDto userDto = userService.updateUser(id);
        return userDto.toString();
    }

    @GetMapping("delete")
    public String delete(Integer id) {
        userService.delete(id);
        return "删除完成";
    }

}
